<?php
/**
 * Created by PhpStorm.
 * User: sakura
 * Date: 2019/4/26
 * Time: 11:48 AM
 */

namespace app\admin\validate;


use app\common\validate\Validate;

class Driver extends Validate
{
    protected $rule = [
        'name|帐号'     => 'require|unique:driver',
        'password|密码' => 'require',
        'nickname|昵称' => 'require',
        'mobile|手机号'  => ['require', 'regex' => '/^1(3|4|5|6|7|8|9)[0-9]\d{8}$/'],
        'email|邮箱'    => 'email',
        'id_card|身份证' => ['require', 'regex' => '/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/'],
        'status|状态' => 'require',
    ];

    protected $message = [
        'email.email'  => '邮箱格式错误',
        'mobile.regex' => '手机格式错误',
        'id_card.regex' => '身份证格式错误',
    ];

    protected $scene = [
        'driver_add'   => ['name', 'password', 'nickname','id_card'],
        'driver_edit'  => [ 'name', 'nickname','id_card'],
        'login' => ['name' => 'require', 'password'],
    ];
}